﻿using System;
using Autofac;

namespace Zinnia.Lite.Services
{
    /// <summary>
    /// 容器生命周期服务接口
    /// </summary>
    public interface IContainerScopeService
    {
        ILifetimeScope Scope();
    }
    /// <summary>
    /// 容器解析服务接口
    /// </summary>
    public interface IContainerResolveService
    {
        /// <summary>
        /// AutoFac容器
        /// </summary>
        IContainer Container { get; }
        T Resolve<T>(string key = "", ILifetimeScope scope = null) where T : class;
        object Resolve(Type type, ILifetimeScope scope = null);
        T[] ResolveAll<T>(string key = "", ILifetimeScope scope = null);
        T ResolveUnregistered<T>(ILifetimeScope scope = null) where T : class;
        object ResolveUnregistered(Type type, ILifetimeScope scope = null);
        bool TryResolve(Type serviceType, ILifetimeScope scope, out object instance);
        bool IsRegistered(Type serviceType, ILifetimeScope scope = null);
        object ResolveOptional(Type serviceType, ILifetimeScope scope = null);
    }

    /// <summary>
    /// 服务接口容器
    /// </summary>
    public interface IContainerService : IContainerScopeService, IContainerResolveService
    {
    }
}
